#ifndef __LWMPEG_H__
#define __LWMPEG_H__

#include <stdlib.h>
#include "../mp2dec/mp2dec/config.h"

#ifdef __cplusplus
#	define LWMPEG_LINKAGE MP2DEC_CPP_LINKAGE
#else
#	define LWMPEG_LINKAGE MP2DEC_C_LINKAGE
#endif

typedef struct LWMPEG_Allocator
{
	void *(*allocfunc) (void *opaque, size_t sz);
	void (*freefunc) (void *opaque, void *ptr);
	void *opaque;
} LWMPEG_Allocator_t;

typedef struct LWMPEG_VideoDecodeState LWMPEG_VideoDecodeState_t;

LWMPEG_LINKAGE LWMPEG_VideoDecodeState_t *LWMPEG_CreateDecodeState(const LWMPEG_Allocator_t *alloc);
LWMPEG_LINKAGE void LWMPEG_DestroyDecodeState(LWMPEG_VideoDecodeState_t *state);

LWMPEG_LINKAGE size_t LWMPEG_BytesFree(const LWMPEG_VideoDecodeState_t *state);
LWMPEG_LINKAGE void LWMPEG_FeedData(LWMPEG_VideoDecodeState_t *state, const void *data, size_t size);
LWMPEG_LINKAGE void LWMPEG_Work(LWMPEG_VideoDecodeState_t *state);
LWMPEG_LINKAGE int LWMPEG_GetAudio(LWMPEG_VideoDecodeState_t *state, const short **leftChannel, const short **rightChannel, unsigned int *sampleRate,
	unsigned int *numChannels, unsigned int *numSamples);

LWMPEG_LINKAGE int LWMPEG_GetImage(LWMPEG_VideoDecodeState_t *state, unsigned int *frameRateNum, unsigned int *frameRateDenom,
	unsigned int *width, unsigned int *height, unsigned int *lpitch, unsigned int *cpitch,
	const unsigned char **yPlane, const unsigned char **uPlane, const unsigned char **vPlane);

LWMPEG_LINKAGE void LWMPEG_SetFrameSkip(LWMPEG_VideoDecodeState_t *state, int numFrames);
LWMPEG_LINKAGE void LWMPEG_Flush(LWMPEG_VideoDecodeState_t *state);
LWMPEG_LINKAGE int LWMPEG_Exhausted(LWMPEG_VideoDecodeState_t *state);

#endif
